package com.demo.app;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;

@Controller
public class testContrl {
	@RequestMapping("test")
	@ResponseBody
	public String test() {
		return "hello world!";
	}


	@RequestMapping("login")
	public String login() {
		return "/webdemo/login";
	}
	
	@RequestMapping("index")
	public String index() {
		return "/webdemo/index";
	}

	
	@RequestMapping(value = "test1", method = RequestMethod.POST)
	@ResponseBody
	public String test1(Model model) {

		String xx = "测试";
		model.addAttribute("name", xx);
		return "app";
	}

	@RequestMapping(value = "test4", method = RequestMethod.GET)
	@ResponseBody
	public String test4() {
		RestTemplate restTemplate = new RestTemplate();
		String result = restTemplate.getForObject("http://www.baidu.com", String.class);
		return result;
	}

}
